{% import "admin/macro.html.twig" as admin_macro %}
{% extends 'admin/order/layout.html.twig' %}

{% block title %}{{'admin.money_records.content_title'|trans}} - {{ parent() }}{% endblock %}

{% set menu = 'money_records' %}

{% block main %}
  <div class="page-header">
    <h1>{{'admin.money_records.content_title'|trans}}</h1>
  </div>

  <form id="message-search-form" class="form-inline well well-sm" action="" method="get" novalidate>
    <div class="form-group">
      <select class="form-control" name="type">
        {{ select_options(dict('moneyRecordType'), app.request.query.get('type'), 'admin.money_records.money_record_type.default'|trans) }}
      </select>
    </div>
    <div class="form-group">
      <input class="form-control" type="text" placeholder="{{'admin.money_records.transaction_no.input_placeholder'|trans}}" name="transactionNo" value="{{ app.request.get('transactionNo') }}">
    </div>
    <div class="form-group">
      <input class="form-control" type="text" placeholder="{{'admin.money_records.nickname.input_placeholder'|trans}}" name="nickname" value="{{ app.request.get('nickname') }}">
    </div>

    <button class="btn btn-primary">{{'form.btn.search'|trans}}</button>
  </form>

  <table class="table table-striped table-hover" id="record-table">
    <thead>
      <tr>
        <th>{{'admin.money_records.id'|trans}}</th>
        <th width="20%">{{'admin.money_records.amount'|trans}}</th>
        <th>{{'admin.money_records.name'|trans}}</th>
        <th>{{'admin.money_records.money_record_type'|trans}}</th>
        <th>{{'admin.money_records.person'|trans}}</th>
        <th>{{'admin.money_records.transaction_no'|trans}}</th>
        <th>{{'admin.money_records.transaction_time'|trans}}</th>
      </tr>
    </thead>
    <tbody>
      {% for record in records %}
        {% set user = users[record.userId]|default(null) %}
        <tr>
          <td>{{ record.id }}</td>
          <td><span class="money-text">{{ record.amount }}</span></td>
          <td>{{ record.title }}</td>
          <td>{{ record.type }}</td>
          <td>{{ admin_macro.user_link(user) }}</td>
          <td>{{ record.transactionNo }}</td>
          <td>{{ record.transactionTime|date('Y-n-d H:i') }}</td>
        </tr>
      {% else %}
        <tr><td colspan="20"><div class="empty">{{'admin.money_records.empty_tips'|trans}}</div></td></tr>
      {% endfor %}
    </tbody>

	</table>
  {{ admin_macro.paginator(paginator) }}

{% endblock %}